<?php

	$site_root = "";
	require_once ($site_root . "common/PinSQL.obj");
	$pinSQL = new PinSQL();

	$username = $_POST['username'];
	$password1 = $_POST['password1'];
	$password2 = $_POST['password2'];
	$email = $_POST['email'];
	$firstname = $_POST['firstname'];
	$lastname = $_POST['lastname'];
	
	if ($username != "")
	{
		$userSplit1 = explode(" ", $username);
		
		if ( !$userSplit1[1] )
		{
		
			$pinSQL->Query("SELECT * FROM members WHERE username='$username'");
			if ( $pinSQL->GetNumRows() )
			{
				//username exists!
				echo "0,The username $username is taken.";
			} else {
				if ( $password1 != $password2 )
				{
					//passwords don't match
					echo "0,Your passwords do not match.";
				} else {
					if ( $password1 != "" )
					{	
						echo "1,";
						
					} else {
						echo "0,You must type a password.";
					}
				}
			}
			
		} else {
			echo "0,Usernames with spaces are expressly forbidden. Please remove the offending character and try again.";
		}
			
	} else {
		echo "0,You must type a username.";
	}
	
	$pinSQL->Close();
?>